﻿@{
    Layout = "~/Views/Shared/_Layout_RTU_block.cshtml";
    ViewBag.Title = "Reports";
}

<div class="xds-no-breadcrumb">

    <div class="full-height">
        <div class="full-height-scroll white-bg border-left">
            <div class="row">
                <div class="col-md-12" style="padding:10px">
                    <div class="col-md-6 col-md-offset-3">
                        <div class="col-md-4" style="text-align:right;padding:8px">
                            选择时间：
                        </div>
                        <div class="col-md-4" id="datetime" style="padding:2px">
                            <div class="input-daterange input-group" id="datepicker">
                                <input type="text" class="input-sm form-control" name="start" id="date" />
                            </div>
                        </div>
                        <div class="col-md-4">
                            <button type="button" onclick="confirm()" class="btn btn-w-m btn-primary" style="float:right;">确定</button>
                        </div>
                    </div>
                    <div class="col-md-3">
                        <button type="button" onclick="exportdata()" class="btn btn-w-m btn-primary" style="float:right;">导出报表</button>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-md-12">
                    <div class="panel panel-primary" id="list-panel">
                        <div class="panel-body">
                            <table id="assets-data-table" class="table table-striped table-bordered" style="width:100%"></table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@section Styles {
    @Styles.Render("~/Content/datatables")
    @Styles.Render("~/plugins/dataPickerStyles")
    @Styles.Render("~/plugins/sweetAlertStyles")
    <style type="text/css">
        .panel-primary > .panel-heading {
            background-color: white !important;
        }

        .panel-title {
            color: black !important;
        }
    </style>
}

@section Scripts {
    @Scripts.Render("~/bundles/datatables")
    @Scripts.Render("~/plugins/dataPicker")
    @Scripts.Render("~/plugins/sweetAlert")
    <script type="text/javascript">
        var assetListVM;
        assetListVM = {
            dt: null,
            reload: function () {
                dt.ajax.url("@Url.Action("Get", "Report")" + "?time=" + $("#date").val());
            },
            init: function () {
                dt = $("#assets-data-table").DataTable({
                    "serverSide": true,
                    "proccessing": true,
                    "ajax": {
                        "url": "@Url.Action("Get","Report")" + "?time=" + $("#date").val()
                    },
                    "columns": [
                        { "title": "区块", "data": "BlockId", "searchable": true },
                        { "title": "井号", "data": "WellId", "searchable": true },
                        { "title": "抽油机型号", "data": "XingHao", "searchable": true },
                        { "title": "层位", "data": "CengWei", "searchable": true },
                        { "title": "井段", "data": "JingDuan", "searchable": true },
                        { "title": "生产时间", "data": "Time" },
                        { "title": "冲程", "data": "ChongCheng" },
                        { "title": "冲次", "data": "ChongCi" },
                        { "title": "套压", "data": "TaoYa" },
                        { "title": "回压", "data": "HuiYa" },
                        { "title": "温度", "data": "WenDu" },
                        { "title": "油量", "data": "YouLiang" },
                        { "title": "水量", "data": "ShuiLiang" },
                        { "title": "气量", "data": "QiLiang" }
                    ],
                    "lengthMenu": [[10, 25, 50, 100], [10, 25, 50, 100]],
                    //"language": {
                    //    "processing": "处理中...",
                    //    "lengthMenu": "显示 _MENU_ 项结果",
                    //    "zeroRecords": "没有匹配结果",
                    //    "info": "显示第 _START_ 至 _END_ 项结果，共 _TOTAL_ 项",
                    //    "infoEmpty": "显示第 0 至 0 项结果，共 0 项",
                    //    "infoFiltered": "(由 _MAX_ 项结果过滤)",
                    //    "infoPostFix": "",
                    //    "search": "搜索:",
                    //    "searchPlaceholder": "搜索...",
                    //    "url": "",
                    //    "emptyTable": "表中数据为空",
                    //    "loadingRecords": "载入中...",
                    //    "infoThousands": ",",
                    //    "paginate": {
                    //        "first": "首页",
                    //        "previous": "上页",
                    //        "next": "下页",
                    //        "last": "末页"
                    //    },
                    //    "aria": {
                    //        paginate: {
                    //            first: '首页',
                    //            previous: '上页',
                    //            next: '下页',
                    //            last: '末页'
                    //        },
                    //        "sortAscending": ": 以升序排列此列",
                    //        "sortDescending": ": 以降序排列此列"
                    //    },
                    //    "decimal": "-",
                    //    "thousands": ","
                    //}
                });
            }
        };
        $(document).ready(function () {
            $("#date").attr("value", new Date().getFullYear() + "/" + (new Date().getMonth() + 1) + "/" + new Date().getDate());
            $('#datetime .input-daterange').datepicker({
                keyboardNavigation: false,
                forceParse: false,
                autoclose: true
            });
        });
        function refresh() {
            //assetListVM.reload();
        }
        function confirm() {
            assetListVM.init();
        }
        function exportdata() {
            var form = $("<form>");//定义一个form表单
            form.attr("style", "display:none");
            form.attr("target", "");
            form.attr("method", "post");
            form.attr("action", "/Report/ExportExcel");
            var input1 = $("<input>");
            input1.attr("type", "hidden");
            input1.attr("name", "time");
            input1.attr("value", $("#date").val());
            $("body").append(form);//将表单放置在web中
            form.append(input1);

            form.submit();//表单提交 
        }
    </script>
}




